package com.xi.controller;

import com.xi.pojo.BorrowQueryParam;
import com.xi.pojo.PageResult;
import com.xi.pojo.Result;
import com.xi.service.BorrowService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/borrow")
public class BorrowController {

    @Autowired
    private BorrowService borrowService;

    /*
    * 分页查询借阅记录
    * */
    @GetMapping
    public Result page(BorrowQueryParam borrowQueryParam) {
        log.info("分页查询借阅记录");
        PageResult pageResult = borrowService.page(borrowQueryParam);
        return Result.success(pageResult);
    }

    /*
    * 借阅信息删除，根据id
    * */
    @DeleteMapping()
    public Result delete(Integer id) {
        log.info("删除借阅记录 , {}", id);
        borrowService.deleteById(id);
        return Result.success();
    }
}
